package com.hualan.sfzy.service.psyc.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.entity.PsycKnowledge;
import com.hualan.sfzy.mapper.psyc.PsycKnowledgeMapper;
import com.hualan.sfzy.service.psyc.PsycKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PsycKnowledgeServiceImpl implements PsycKnowledgeService {
    @Autowired
    private PsycKnowledgeMapper psycKnowledgeMapper;

    @Override
    public List<PsycKnowledge> findAll() {
        return psycKnowledgeMapper.selectPsycKnowledgeAndCounselorAll();
    }

    @Override
    public int add(PsycKnowledge entity) {
        return 0;
    }


    public int addSelective(PsycKnowledge entity) {
        return psycKnowledgeMapper.insert(entity);
    }


    @Override
    public int edit(PsycKnowledge entity) {
        return psycKnowledgeMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return psycKnowledgeMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return psycKnowledgeMapper.deleteBatch(ids);
    }

    @Override
    public List<PsycKnowledge> find() {
        return Collections.emptyList();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, PsycKnowledge entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<PsycKnowledge> list = psycKnowledgeMapper.fuzzySelectPsycKnowledgeAndCounselor(entity);
        PageInfo<PsycKnowledge> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put("pageInfo", pageInfo);
        return map;
    }

    @Override
    public PsycKnowledge findById(Integer id) {

        return psycKnowledgeMapper.selectById(id);
    }
}
